<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="股东管理">
<style>
    .form-horizontal .controls {
        line-height: 40px;
        height: 40px;
        margin-left: 3px;
    }

    .button-primary {
        margin-left: -10px;
    }

    .button-danger {
        margin-left: -25px;
    }
</style>
<!--suppress ALL -->
<form id="searchForm" class="form-panel" action="${basepath}/rest/manage/user/selectPartnerPage">
    <ul class="panel-content">
        <li>
            <div class="control-group span5">
                <div class="search-controls  controls">
                    <input type="text" name="nickname" id="nickname" value="" placeholder="搜索关键字">
                </div>
            </div>
            <div class="form-actions span2">
                <button type="submit" class="button  button-primary">
                    搜索
                </button>
            </div>
        </li>
    </ul>
</form>
<div id="grid"></div>
<#----------------------------------------------入股店铺start--------------------------------------------------------->
<div id="editContent" style="display:none;">
    <form id="editForm" class="form-horizontal">
        <div class="row">
            <div class="rowShop">

            </div>

        </div>
    </form>
</div>
<#----------------------------------------------入股店铺end--------------------------------------------------------->
<script>
    var Grid = BUI.Grid,
            Store = BUI.Data.Store,
            columns = [
                {title: '序号', dataIndex: 'id', elCls: 'center', width: '5%'},
                {title: '用户名称', dataIndex: 'nickname', elCls: 'center', width: '10%'},
                {
                    title: '用户角色', dataIndex: 'rid', elCls: 'center', width: '10%', renderer: function (value) {
                        switch (value) {
                            case '2':
                                return '股东';
                            case '3':
                                return '会员';
                            case '4':
                                return '普通用户';
                        }
                    }
                },
                {title: '上级', dataIndex: 'parentname', elCls: 'center', width: '10%'},
                {
                    title: '入股店铺', dataIndex: 'id', elCls: 'center', width: '20%', renderer: function (value) {
                        return '<a href="javascript:shopDetail(' + value + ')">查看</a>';
                    }
                },
                {
                    title: '等级优惠', dataIndex: 'frontIDcart', elCls: 'center', width: '10%', renderer: function (value) {
                        return '70%';
                    }
                },
                {title: '账户收益', dataIndex: 'income', elCls: 'center', width: '10%'},
                {
                    title: '我的团队', dataIndex: 'id', elCls: 'center', width: '10%', renderer: function (value, data) {
                        return '<a href="${basepath}/rest/manage/account/toMyTeam?id=' + value + '&rid=' + data.rid + '&nickname=' + data.nickname + '">查看</a>';
                    }
                },
                {
                    title: '收益流水', dataIndex: 'id', elCls: 'center', width: '15%', renderer: function (value) {
                        return '<a href="${basepath}/rest/manage/account/toMyIncome?id=' + value + '">查看</a>';
                    }
                }
            ];
    //分页查询
    var store = new Store({
        url: '/rest/manage/account/selectPartnerPage',
        autoLoad: true, //自动加载数据
        params: { //配置初始请求的参数
            length: '10'
        },
        pageSize: 10,	// 配置分页数目
        root: 'list',
        totalProperty: 'total'
    });
    grid = new Grid.Grid({
        render: '#grid',
        columns: columns,
        loadMask: true, //加载数据时显示屏蔽层
        store: store,
        plugins: [Grid.Plugins.CheckSelection], // 插件形式引入多选表格
        // 底部工具栏
        bbar: {
            pagingBar: true
        }
    });

    grid.render();
    /*--------------------------------模糊查询---------------------------------------------*/
    var form = new BUI.Form.HForm({
        srcNode: '#searchForm'
    }).render();

    form.on('beforesubmit', function (ev) {
        //序列化成对象
        var obj = form.serializeToObject();
        obj.start = 0; //返回第一页
        store.load(obj);
        return false;
    });
    /*--------------------------------模糊查询---------------------------------------------*/
    /*------------------------------------------------查询入股店铺 start-----------------------------------------------*/
    var editForm = new BUI.Form.Form({
        srcNode: '#editForm',
        submitType: 'ajax',
        callback: function (data) {
            var obj = new Object();
            obj.start = 0; //返回第一页
            store.load(obj);
            editDialog.close();
        }
    });
    editForm.render();

    var editDialog = new BUI.Overlay.Dialog({
        title: '入股店铺',
        width: 400,
//        height: 320,
        contentId: 'editContent',
        success: function () {
        }
    });

    //查询入股店铺
    function shopDetail(userID) {
        $.ajax({
            type: "GET",
            dataType: "json",
            url: "${basepath}/rest/manage/account/selectStoreList",
            data: {userID: userID},
            success: function (data) {
                var shopHtml = "";
                //查询入股店铺
                if (data.data == '' || data.data == null) {
                    shopHtml += '<div class="control-group span16"><label class="control-label">入股店铺：</label><div class="controls">' +
                            '<input type="text" class="input-normal control-text" value="无"  disabled>' +
                            '</div></div>';
                } else {
                    $.each(data.data, function (i, o) {
                        shopHtml += '<ul class="underline"><li class=" item flex "><div class="control-group span16"><label class="control-label">入股店铺' + (i + 1) + '：</label><div class="controls">' +
                                '<input type="text" class="input-normal control-text" value="' + o.storeName + '" disabled>' +
                                '</li></ul></div></div>\n'+
                                '<ul class="underline"><li class=" item flex "><div class="control-group span16"><label class="control-label">入股时间：</label><div class="controls">' +
                                '<input type="text" class="input-normal control-text" value="' + o.updateTime + '" disabled>' +
                                '</li></ul></div></div>\n';
                    })
                }
                $(".rowShop").html(shopHtml);
                editDialog.show();
                $(".bui-stdmod-footer").hide();//隐藏弹出框的确定与取消
            }
        });
    }

    /*------------------------------------------------查询入股店铺 end-----------------------------------------------*/
</script>

</@page.pageBase>
